﻿using System;
using System.Collections;
using ApplicationGenerator.BusinessModule.Interfaces;

namespace ApplicationGenerator.BusinessModule.MetaElements
{
    /// <summary>
    /// Kolekcja definicji meta słowników
    /// </summary>
    internal class MetaDictionaryCollection : DictionaryBase, IMetaDictionaryCollection
    {
        public void Add(IMetaDictionary metaDictionary)
        {
            try
            {
                Dictionary.Add(metaDictionary.DictionaryName, metaDictionary);
            }
            catch
            {
                throw new ArgumentException("Nie można zarejestrować w kolekcji modeli o takich samych nazwach." + metaDictionary.DictionaryName);
            }
        }

        public bool Contains(string metaDictionary)
        {
            return Dictionary.Contains(metaDictionary);
        }

        public IMetaDictionary this[string metaDictionary]
        {
            get { return Dictionary[metaDictionary] as IMetaDictionary; }
        }

        #region IEnumerable Members

        public new IEnumerator GetEnumerator()
        {
            return Dictionary.Values.GetEnumerator();
        }

        #endregion
    }
}
